#ifndef CL_WRAPPER_HPP
#define CL_WRAPPER_HPP

#include "Types.hpp"
#include <iostream>
#include <string>
#include <vector>
#include <ostream>
#include <stdexcept>

class ClWrapper {
	std::vector<cl::Platform> platforms;

public:	

	ClWrapper()
	{
		cl::Platform::get(&platforms);
	}

	ClWrapper(cl::Platform &plat)
	{
		platforms.push_back(plat);
	}
	cl::Platform getPlatform()
	{
		if (platforms.size() ==1)
			return platforms[0];
		else
		{
			std::cout << "\n\nPlease enter the Platform Number to be selected: (0 to  " << platforms.size()-1 << " ):"<< std::endl;
			unsigned i;
			std::cin >> i;
			if (i >(platforms.size()-1) )
			{
				std::cerr <<" Incorrect Number entered. Exiting" ;
				system("pause");
				exit(EXIT_FAILURE);				
			}
			else
				return platforms[i];	
		}		
	}
    inline void printPlatforms(std::ostream& os);
};

inline void ClWrapper::printPlatforms(std::ostream& os)
{
    for(std::size_t i = 0; i < platforms.size(); ++i)
	{
		os<< "Platform #" << i << ":" << std::endl;
        os<< "CL_PLATFORM_VERSION\t= " << platforms[i].getInfo<CL_PLATFORM_VERSION>() << std::endl;
        os<< "CL_PLATFORM_NAME\t= " << platforms[i].getInfo<CL_PLATFORM_NAME>() << std::endl;
        os<< "CL_PLATFORM_VENDOR\t= " << platforms[i].getInfo<CL_PLATFORM_VENDOR>() << std::endl;
        os<< "CL_PLATFORM_EXTENSIONS\t= " << platforms[i].getInfo<CL_PLATFORM_EXTENSIONS>() << std::endl;
	}
}
#endif //CL_WRAPPER_HPP
